package dao;

import vo.Custom;
import vo.Furniture;

import java.util.List;

public class FurnitureDaoimpl extends BaseDao implements IFurniture {//对家具表的具体实现类 继承BaseDao类是为了使用对数据库进行操作的方法,来实现其接口类的操作
    @Override
    public boolean add(Furniture furniture) { //添加
        String sql="insert into furniture values(?,?,?,?);";
        return update(sql,furniture.getId(),furniture.getType(),furniture.getPrice(),furniture.getCount());
    }

    @Override
    public boolean delete(Furniture furniture) {
        String sql="delet from furniture where id=?";//通过id删除家具信息
        return update(sql,furniture.getId());
    }

    @Override
    public boolean modify(Furniture furniture) {
        String sql="update furniture set id=?,type=?,price=?,count=? where id=?";// 传入一个修改后的家具信息,通过修后的id来找到对应的信息
        return update(sql,furniture.getId(),furniture.getType(),furniture.getPrice(),furniture.getCount(),furniture.getId());
    }

    @Override
    public Furniture getcustombyid(String id) {
        String sql="select*from furniture where id=?";
        return getInstance(Furniture.class,sql,id);//按照id查询
    }

    @Override
    public List<Furniture> getall() {
        String sql="select*from custom";
        List<Furniture> list=getList(Furniture.class,sql);//查询到的所有信息
        return list;
    }

}
